package cn.tedu.v1.mapper;

import cn.tedu.v1.model.Drug;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 药品列表 Mapper 接口
 * </p>
 *
 * @author tedu.cn
 * @since 2021-07-06
 */
@Repository
public interface DrugMapper extends BaseMapper<Drug> {

    @Update("update drug set count=count+#{count} where name=#{medicine}")
    void addDrug(String medicine, Integer count);

    @Update("update drug set count=count-#{count} where name=#{medicine}")
    void subDrug(String medicine, Integer count);

    @Select("select price from drug where name=#{drug}")
    int getpriceByName(String drug);
}
